package top.xchch.tool.resttemplate.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.xchch.tool.resttemplate.entity.Poetry;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sai.zhang
 * @date 2021-09-12 9:35
 */
@RestController
@Slf4j
public class GetMappingController {

    @GetMapping("/findInIds")
    public List<Poetry> findInIds(@RequestParam("id") List<Long> ids, String name){
        // 输出 ids: [10, 20], name: hah
        log.info("ids: {}, name: {}", ids, name);
        Poetry poetry = new Poetry();
        poetry.setId(666106231640L);
        poetry.setTitle("西塞山二首");
        poetry.setAuthor("王周");
        poetry.setContent("西塞名山立翠屏，浓岚横入半江青。\n千寻铁锁无由问，石壁空存道者形。\n匹妇顽然莫问因，匹夫何去望千春。\n翻思岵屺传诗什，举世曾无化石人。");

        List<Poetry> poetries = new ArrayList<>();
        poetries.add(poetry);
        return poetries;
    }

    @GetMapping("/findInIds2")
    public List<Poetry> findInIds2(@RequestParam("id") List<Long> ids, String name){
        // ids: [11, 21], name: haha
        log.info("ids: {}, name: {}", ids, name);
        Poetry poetry = new Poetry();
        poetry.setId(666106231640L);
        poetry.setTitle("西塞山二首");
        poetry.setAuthor("王周");
        poetry.setContent("西塞名山立翠屏，浓岚横入半江青。\n千寻铁锁无由问，石壁空存道者形。\n匹妇顽然莫问因，匹夫何去望千春。\n翻思岵屺传诗什，举世曾无化石人。");

        List<Poetry> poetries = new ArrayList<>();
        poetries.add(poetry);
        return poetries;
    }

    @GetMapping("/findInIds3")
    public List<Poetry> findInIds3(@RequestParam("id") List<Long> ids, String name){
        // ids: [10], name: hah
        log.info("ids: {}, name: {}", ids, name);
        Poetry poetry = new Poetry();
        poetry.setId(666106231640L);
        poetry.setTitle("西塞山二首");
        poetry.setAuthor("王周");
        poetry.setContent("西塞名山立翠屏，浓岚横入半江青。\n千寻铁锁无由问，石壁空存道者形。\n匹妇顽然莫问因，匹夫何去望千春。\n翻思岵屺传诗什，举世曾无化石人。");

        List<Poetry> poetries = new ArrayList<>();
        poetries.add(poetry);
        return poetries;
    }
}
